sp = input()
k = ""
for i in range(len(sp)):
    if sp[i] in "([{<":
        k += sp[i]
    else:
        if len(k) != 0 and ((k[-1] == '(' and sp[i] == ')') or (k[-1] == '[' and sp[i] == ']') or (k[-1] == '{' and sp[i] == '}') or (k[-1] == '<' and sp[i] == '>')):
            k = k[:-1]
        else:
            print("False")
            break
else:
    if len(k) == 0:
        print("True")
    else:
        print("False")
